home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume8 / gnuplot1.10A / part01 next >
Encoding:
Text File  |  1989-09-09  |  57.8 KB  |  2,259 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v08i035: GnuPlot v1.10A (part 1 of 7)
  4. Reply-To: canoaf@ntvax.UUCP (Augustine Cano)
  5.  
  6. Posting-number: Volume 8, Issue 35
  7. Submitted-by: canoaf@ntvax.UUCP (Augustine Cano)
  8. Archive-name: gnuplot1.10A/part01
  9.  
  10. [OOPS!!!  I had to patch these after receiving them -- and managed to lose the
  11. name of the person who submitted them in the process.  Duh.  The name shown
  12. is a "best guess".  Submitter, please correct me.  ++bsa]
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 1 (of 7)."
  21. # Contents:  1.dat 2.dat 3.dat 3b1.dem README README.3B1 aed.trm
  22. #   bitgraph.trm command.c compile.com controls.dem corgraph.asm
  23. #   corplot.c docs eval.c
  24. # Wrapped by allbery@uunet on Sat Sep  9 13:47:18 1989
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f '1.dat' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'1.dat'\"
  28. else
  29. echo shar: Extracting \"'1.dat'\" \(781 characters\)
  30. sed "s/^X//" >'1.dat' <<'END_OF_FILE'
  31. X-20.000000 -3.041676
  32. X-19.000000 -3.036427
  33. X-18.000000 -3.030596
  34. X-17.000000 -3.024081
  35. X-16.000000 -3.016755
  36. X-15.000000 -3.008456
  37. X-14.000000 -2.998978
  38. X-13.000000 -2.988049
  39. X-12.000000 -2.975310
  40. X-11.000000 -2.960273
  41. X-10.000000 -2.942255
  42. X-9.000000 -2.920278
  43. X-8.000000 -2.892883
  44. X-7.000000 -2.857799
  45. X-6.000000 -2.811295
  46. X-5.000000 -2.746802
  47. X-4.000000 -2.651635
  48. X-3.000000 -2.498092
  49. X-2.000000 -2.214297
  50. X-1.000000 -1.570796
  51. X0.000000 0.000000
  52. X1.000000 1.570796
  53. X2.000000 2.214297
  54. X3.000000 2.498092
  55. X4.000000 2.651635
  56. X5.000000 2.746802
  57. X6.000000 2.811295
  58. X7.000000 2.857799
  59. X8.000000 2.892883
  60. X9.000000 2.920278
  61. X10.000000 2.942255
  62. X11.000000 2.960273
  63. X12.000000 2.975310
  64. X13.000000 2.988049
  65. X14.000000 2.998978
  66. X15.000000 3.008456
  67. X16.000000 3.016755
  68. X17.000000 3.024081
  69. X18.000000 3.030596
  70. X19.000000 3.036427
  71. END_OF_FILE
  72. if test 781 -ne `wc -c <'1.dat'`; then
  73.     echo shar: \"'1.dat'\" unpacked with wrong size!
  74. fi
  75. # end of '1.dat'
  76. fi
  77. if test -f '2.dat' -a "${1}" != "-c" ; then 
  78.   echo shar: Will not clobber existing file \"'2.dat'\"
  79. else
  80. echo shar: Extracting \"'2.dat'\" \(781 characters\)
  81. sed "s/^X//" >'2.dat' <<'END_OF_FILE'
  82. X-20.000000 -6.083352
  83. X-19.000000 -6.072853
  84. X-18.000000 -6.061191
  85. X-17.000000 -6.048162
  86. X-16.000000 -6.033510
  87. X-15.000000 -6.016913
  88. X-14.000000 -5.997955
  89. X-13.000000 -5.976098
  90. X-12.000000 -5.950620
  91. X-11.000000 -5.920546
  92. X-10.000000 -5.884511
  93. X-9.000000 -5.840556
  94. X-8.000000 -5.785765
  95. X-7.000000 -5.715597
  96. X-6.000000 -5.622591
  97. X-5.000000 -5.493603
  98. X-4.000000 -5.303271
  99. X-3.000000 -4.996183
  100. X-2.000000 -4.428595
  101. X-1.000000 -3.141593
  102. X0.000000 0.000000
  103. X1.000000 3.141593
  104. X2.000000 4.428595
  105. X3.000000 4.996183
  106. X4.000000 5.303271
  107. X5.000000 5.493603
  108. X6.000000 5.622591
  109. X7.000000 5.715597
  110. X8.000000 5.785765
  111. X9.000000 5.840556
  112. X10.000000 5.884511
  113. X11.000000 5.920546
  114. X12.000000 5.950620
  115. X13.000000 5.976098
  116. X14.000000 5.997955
  117. X15.000000 6.016913
  118. X16.000000 6.033510
  119. X17.000000 6.048162
  120. X18.000000 6.061191
  121. X19.000000 6.072853
  122. END_OF_FILE
  123. if test 781 -ne `wc -c <'2.dat'`; then
  124.     echo shar: \"'2.dat'\" unpacked with wrong size!
  125. fi
  126. # end of '2.dat'
  127. fi
  128. if test -f '3.dat' -a "${1}" != "-c" ; then 
  129.   echo shar: Will not clobber existing file \"'3.dat'\"
  130. else
  131. echo shar: Extracting \"'3.dat'\" \(781 characters\)
  132. sed "s/^X//" >'3.dat' <<'END_OF_FILE'
  133. X-20.000000 -9.125028
  134. X-19.000000 -9.109280
  135. X-18.000000 -9.091787
  136. X-17.000000 -9.072243
  137. X-16.000000 -9.050265
  138. X-15.000000 -9.025369
  139. X-14.000000 -8.996933
  140. X-13.000000 -8.964147
  141. X-12.000000 -8.925931
  142. X-11.000000 -8.880819
  143. X-10.000000 -8.826766
  144. X-9.000000 -8.760835
  145. X-8.000000 -8.678648
  146. X-7.000000 -8.573396
  147. X-6.000000 -8.433886
  148. X-5.000000 -8.240405
  149. X-4.000000 -7.954906
  150. X-3.000000 -7.494275
  151. X-2.000000 -6.642892
  152. X-1.000000 -4.712389
  153. X0.000000 0.000000
  154. X1.000000 4.712389
  155. X2.000000 6.642892
  156. X3.000000 7.494275
  157. X4.000000 7.954906
  158. X5.000000 8.240405
  159. X6.000000 8.433886
  160. X7.000000 8.573396
  161. X8.000000 8.678648
  162. X9.000000 8.760835
  163. X10.000000 8.826766
  164. X11.000000 8.880819
  165. X12.000000 8.925931
  166. X13.000000 8.964147
  167. X14.000000 8.996933
  168. X15.000000 9.025369
  169. X16.000000 9.050265
  170. X17.000000 9.072243
  171. X18.000000 9.091787
  172. X19.000000 9.109280
  173. END_OF_FILE
  174. if test 781 -ne `wc -c <'3.dat'`; then
  175.     echo shar: \"'3.dat'\" unpacked with wrong size!
  176. fi
  177. # end of '3.dat'
  178. fi
  179. if test -f '3b1.dem' -a "${1}" != "-c" ; then 
  180.   echo shar: Will not clobber existing file \"'3b1.dem'\"
  181. else
  182. echo shar: Extracting \"'3b1.dem'\" \(493 characters\)
  183. sed "s/^X//" >'3b1.dem' <<'END_OF_FILE'
  184. Xset yrange [-40:40]
  185. Xset samples 8
  186. Xplot -20,-18,-16,-14,-4,-6,-8,-10
  187. Xset yrange [-1.4:1.4]
  188. Xset xrange [-3*pi:3*pi]
  189. Xset samples 90
  190. Xplot sin(x),sin(x+1),sin(x+2),sin(x+3)
  191. Xset yrange [-3:3]
  192. Xplot sin(x)**2+cos(x)**2,sin(x)**2,cos(x)**2
  193. Xplot cos(x), 3*exp(-x**2.0/3.0), -1/cos(x)**2
  194. Xnormal(x) = 1/sqrt(2*pi)*exp(-x**2/(2*pi))
  195. Xset autoscale
  196. Xplot normal(x)
  197. Xset samples 360
  198. Xset yrange [-.2:.5]
  199. Xset function style impulse
  200. Xreplot
  201. Xset xrange [-10:10]
  202. Xset autoscale
  203. Xset function style line
  204. Xset samples 160
  205. END_OF_FILE
  206. if test 493 -ne `wc -c <'3b1.dem'`; then
  207.     echo shar: \"'3b1.dem'\" unpacked with wrong size!
  208. fi
  209. # end of '3b1.dem'
  210. fi
  211. if test -f 'README' -a "${1}" != "-c" ; then 
  212.   echo shar: Will not clobber existing file \"'README'\"
  213. else
  214. echo shar: Extracting \"'README'\" \(7021 characters\)
  215. sed "s/^X//" >'README' <<'END_OF_FILE'
  216. X---------  Version 1.10A (Polar) README file ---------
  217. X
  218. XVersion 1.1.0A (Polar) of GNUPLOT includes ATT3b1 support and the commands
  219. XSET POLAR, SET OFFSETS, and PAUSE.  Additionally, some bugs were fixed
  220. Xand new improved IBM-PC drivers were written in TURBO-C.  The file version.c
  221. Xcontains a synopsis of differences between this GNUPLOT and version 1.1.0.
  222. X
  223. XAll that is needed to make gnuplot work is the gnuplot executable.  Every
  224. Xthing else can be removed.  The help command, however, won't work without a
  225. Xhelp executable and a gnuplot help directory tree.  Gnuplot actually executes
  226. Xsystem(GNUHELP) to run the help command where GNUHELP is an environment
  227. Xvariable that contains the string to be executed.  On unix this string might
  228. Xbe GNUHELP="/usr/local/bin/help gnuplot".
  229. X
  230. XNote that there is no file called "Makefile" in the main directory.  Three
  231. Xdifferent makefiles are used for the 3 varieties of system where GNUPLOT
  232. Xis known to run: makefile.unx for UNIX systems (tested on ULTRIX),
  233. Xmakefile.3b1 for the UNIX PC (tested on System V 3.51a) and makefile.tc
  234. Xfor PC compatibles running DOS and Turbo C. Copy the appropriate one for
  235. Xyour system to "Makefile" and "make" the system.
  236. X
  237. XIn the help system directory, 2 makefiles are provided: makefile.unx
  238. Xfor all UNIX systems (including the UNIX PC) and makefile.tc for Turbo C.
  239. XAs above, copy the correct one for your system to "Makefile".
  240. X
  241. XThe help system supplied with this distribution will look first for an
  242. Xenvironment variable called HELPDIR and then in /usr/local/help for the
  243. Xdirectory tree requested.  PC users will probably want to define HELPDIR
  244. Xto be the root directory that contains the gnuplot directory tree.
  245. X
  246. XOh yes, our attempts to reach vu-vlsi!plot failed.  This seems to also
  247. Xbe the case for David F. Kotz <dfk@cs.duke.edu> who has developed another
  248. Xvariant of Gnuplot: GnuTeX.  We discussed a merger of these efforts, but
  249. Xhis LaTeX version started from an earlier Gnuplot and has been added to
  250. Xextensively.
  251. X
  252. XWe turn you over now to your regularly scheduled release notes...
  253. X
  254. X---------  Version 1.10 README file ---------
  255. XThe GNUPLOT source code and executables may be copied and/or modified freely
  256. Xas long as the copyright messages are left intact.
  257. X
  258. XGNUPLOT has been tested on a Pyramid 90x (ucb 4.2 and att V), a VAX 8200
  259. X(VMS 4.3), IBM PC's and AT's (MS-DOS 3.1, Microsoft C 4.0).  The code is
  260. Xwritten with portability in mind, and it passes lint!  If you have
  261. Xproblems, send mail to vu-vlsi!plot.  And please send any modifications
  262. Xyou make so they can be #ifdef'd into later releases.
  263. X
  264. X
  265. X                      GNUPLOT 1.1 RELEASE NOTES
  266. X
  267. XNew terminal drivers:  AED 512, BBN BitGraph, HP2623, POSTSCRIPT, Selanar,
  268. XVectrix 384.  The PC version now supports Hercules and ATT 6300 monochrome
  269. Xgraphics.  Thanks to those who sent these drivers in.
  270. X
  271. XNew commands:  'set dummy' and 'show dummy' to select the dummy variable
  272. Xname; 'replot' to repeat the last 'plot' command.
  273. X
  274. XThe exclamation point (!) is now accepted as postfix factorial operator.
  275. XThe gamma() function is also included, if your C library has gamma().  See
  276. XGAMMA below.
  277. X
  278. XLogical AND (&&) and OR (||) now short-circuit the way they do in C.  That
  279. Xis, the second && operand is not evaluated if the first is false; the
  280. Xsecond || operand is not evaluated if the first is true.  The ternary operator
  281. X(?:) also does not evaluate the unused operand.  This change allows for the
  282. Xdefinition of recursive functions, e.g. a synonym for the ! factorial operator:
  283. X
  284. X        fact(x) = (x<=1) ? 1 : x*fact(x-1)
  285. X
  286. XGNUPLOT now has a much better memory allocation scheme, replacing
  287. Xmost fixed-size arrays with malloc()'d linked lists.  There is no longer
  288. Xany artificial maximum on the number of simultaneous plots, number of
  289. Xpoints in those plots, or the number of user-defined functions or
  290. Xvariables.  All these are limited only by the memory available to
  291. Xmalloc().  This is a big improvement for memory-starved machines like
  292. XPDP-11s or PCs.
  293. X
  294. XLines beginning with # (also ! in VMS) are treated as comments.  Only the
  295. X$ may now be used for a shell escape in VMS, since ! is a comment.
  296. X
  297. XThe PC version now has the 'help' command, thanks to code posted by
  298. XRobert Scott.
  299. X
  300. XSeveral old bugs have been superseded by new ones.
  301. X
  302. X
  303. X                       PREPROCESSOR #DEFINES
  304. X
  305. XThese #defines should be checked before compilation:
  306. X
  307. XVFORK       Makefile        define if you've got vfork() system call
  308. XGAMMA       Makefile        define if you've got gamma(3)
  309. XBCOPY       Makefile        define if your memcpy() is called bcopy()
  310. XNOCOPY      Makefile        define if you've don't have a memcpy() by any name
  311. Xbcopy()     plot.h          define if you've got a memcpy() by some OTHER name
  312. X                              (see example in plot.h)
  313. Xvms         Makefile        define if compiling under VMS;
  314. X                              automatically defined by DEC C
  315. XPC          Makefile        define if compiling on a PClone
  316. XMSDOS       Makefile        define if compiling under MSDOS;
  317. X                              automatically defined by Microsoft C 4.0
  318. XAED         Makefile        define these if you want this terminal driver
  319. X                              included
  320. XBITGRAPH       .            (TEK must also be defined)
  321. XHP26           .
  322. XHP75           .
  323. XPOSTSCRIPT     .
  324. XQMS            .
  325. XREGIS          .
  326. XSELANAR        .            (TEK must also be defined)
  327. XTEK            .
  328. XUNIXPLOT       .
  329. XV384           .
  330. X
  331. XHERCULES       .            same, but only if PC is defined
  332. XATT            .
  333. XCORONA         .
  334. X
  335. XHUGE        plot.h          define to be largest double if not defined
  336. X                              in <math.h>
  337. XGNUTERM     plot.h          default terminal type if GNUTERM environment
  338. X                              variable not found at run-time
  339. XHELP        plot.h          default command spawned by 'help' command
  340. X                              if GNUHELP environment variable not found
  341. X                              at run-time
  342. XSHELL       plot.h          default shell to spawn if SHELL environment
  343. X                              variable not found at run-time
  344. X
  345. X
  346. X                             TO COMPILE
  347. X
  348. Xunder UNIX:  type 'make'
  349. X
  350. Xunder VMS:  type '@compile', then '@link'.  Use the gnuplot.hlp file in the
  351. Xdocs directory to build the GNUPLOT.HLB file.
  352. X
  353. Xunder MSDOS:  use 'make make.msc' for Microsoft C 4.0 or make makefile.tc
  354. Xfor Borland Turbo C.  If you've got another compiler, you're on your own!
  355. XFor MSDOS help, use the gnuplot.hlp file to build the gnuplot subtree using
  356. Xthe HELPTREE program.  Borland Turbo-C is the most recent support package,
  357. Xsee README.TC for more information.
  358. X
  359. X
  360. X                         ENVIRONMENT VARIABLES
  361. X
  362. XIf the environment variable GNUTERM is found, it is used as the terminal
  363. Xtype.
  364. X
  365. XIf the environment variable GNUHELP exists, it is used as the command to
  366. Xspawn for help.
  367. X
  368. XThe PC version looks for the environment variable GNUPLOT to contain
  369. Xthe name of the directory from which to load the initialization file
  370. XGNUPLOT.INI.  See the help on 'start_up' for more information.
  371. END_OF_FILE
  372. if test 7021 -ne `wc -c <'README'`; then
  373.     echo shar: \"'README'\" unpacked with wrong size!
  374. fi
  375. # end of 'README'
  376. fi
  377. if test -f 'README.3B1' -a "${1}" != "-c" ; then 
  378.   echo shar: Will not clobber existing file \"'README.3B1'\"
  379. else
  380. echo shar: Extracting \"'README.3B1'\" \(6524 characters\)
  381. sed "s/^X//" >'README.3B1' <<'END_OF_FILE'
  382. X
  383. X                   GNUPLOT
  384. X            Additional notes for users of
  385. X               AT&T Unix PC 7300/3b1
  386. X                     by
  387. X                Augustine Cano
  388. X
  389. X
  390. X    INTRODUCTION
  391. X
  392. X    The following notes address peculiarities, problems, possible
  393. X    improvements and instructions specific the the Unix PC version
  394. X    of GNUPLOT.  The port to the Unix PC was done by John Campbell
  395. X    (CAMPBELL@NAUVAX.bitnet), who also integrated the help system,
  396. X    added polar coordinates and fixed miscellaneous bugs.  I 
  397. X    (Augustine Cano, canoaf@dept.csci.unt.edu) made the makefiles
  398. X    easier to use and was a beta tester.
  399. X
  400. X    The "README" file in this directory contains important information
  401. X    about the different makefiles and how to rename them to "make"
  402. X    GNUPLOT on the various systems supported.  Reading that file
  403. X    and at least the following INSTALLATION section will make it
  404. X    much easier to configure and install GNUPLOT.
  405. X
  406. X
  407. X    INSTALLATION
  408. X
  409. X    The much friendlier makefile.3b1 makes it very easy to install
  410. X    this package.  All that is needed is to "make all" and "make
  411. X    install".  As usual, look over the makefile to make sure that
  412. X    the default destinations do not conflict with anything on your
  413. X    system.
  414. X
  415. X    The distribution consists essentially of three parts: gnuplot
  416. X    itself, the help program and the documentation (which is used to
  417. X    build the help tree used by the help program).  If you want to 
  418. X    look over the details of the sub-systems, look at the makefiles 
  419. X    in ./help and ./docs respectively; otherwise, the top-level 
  420. X    makefile will take care of compiling and installing everything.  
  421. X    It is important that the directory /usr/local/help exist,
  422. X    otherwise the creation of the help tree will fail.
  423. X    The default destinations are as follows:
  424. X
  425. X        gnuplot        - /usr/local/bin
  426. X        manual page    - /usr/man/man1
  427. X        help system    - /usr/local/help
  428. X        help tree root    - /usr/local/help/gnuplot
  429. X
  430. X    Note that this is only relevant to "make install".  If you want to
  431. X    test the system in your current directory, before final installation,
  432. X    you can "make all" and then go to ./docs and create the help tree
  433. X    there.  You will then have to define the following environment
  434. X    variables so that gnuplot knows about the non-standard locations:
  435. X
  436. X        GNUHELP='./help/help gnuplot'
  437. X        HELPDIR='./docs'
  438. X
  439. X    An easy way of testing GNUPLOT is to "load" the .dem files.
  440. X    Typing help at the "gnuplot>" prompt will enter the help system.
  441. X    Step by step instructions are given there.  <RETURN> goes to the
  442. X    previous level and <CTRL D> returns you to GNUPLOT from any level.
  443. X    Two consecutive <RETURN>s at the top level of the help tree will
  444. X    also return to the "gnuplot>" prompt.
  445. X
  446. X    Given that the help system does not have its own Unix-PC specific
  447. X    makefile, if you want to compile it with the shared library, you will
  448. X    have to uncomment the appropriate 'ld' line in help system Makefile.
  449. X
  450. X
  451. X    PROBLEMS, UNIX PC PECULIARITIES, IMPROVEMENTS
  452. X
  453. X    In an attempt to get the program out as soon as possible, it was
  454. X    decided that certain minor problems, incompatibilities with other
  455. X    programs and improvements would be dealt with later.  If you have
  456. X    suggestions, fixes or improvements, send them to John Campbell
  457. X    (jdc@naucse.uucp).
  458. X
  459. X    The primary area of conflict is the larger than 24 lines display
  460. X    of the Unix PC.  Ideally, as much of it should be used in a way
  461. X    that would not make this version radically different from that of
  462. X    other machines.
  463. X
  464. X    One problem was caused by contention between GNUPLOT and sysinfo,
  465. X    the program written by Lenny Tropiano (lenny@icus.islp.ny.us).  This
  466. X    program updates the two bottom lines of the screen (the same ones
  467. X    used by the UA to display the soft key labels) every 15 seconds with
  468. X    miscellaneous system information.  GNUPLOT uses these two lines
  469. X    to display range information, and it would be invariably overwritten
  470. X    in less than 15 seconds.  John created a patch for sysinfo available 
  471. X    for FTP access from dept.csci.unt.edu (IP number 129.120.1.2).  The 
  472. X    file is called sysinfo.patch.  It prevents sysinfo from updating the 
  473. X    two bottom lines if they are being used by another program  (this works
  474. X    with the UA too.)
  475. X
  476. X    In order to have the largest graphics window possible, GNUPLOT uses
  477. X    the uppermost status line, where the date, time, and various icons
  478. X    reside.  When switching to another window, the date, time and icons
  479. X    are not restored and they should be.
  480. X
  481. X    The "gnuplot>" prompt appears inside the graphics window.  Any input
  482. X    makes this window scroll upwards.  It would be much more elegant to
  483. X    to use the line immediately below the graphics screen for input.
  484. X    One possible solution, that would solve this and also free the two
  485. X    bottom lines for sysinfo and the UA, would configure the 4 bottom
  486. X    lines of the screen like this:
  487. X
  488. X|                     bottom of the graphics screen                           |
  489. X_______________________________________________________________________________
  490. Xgnuplot > < this area for input        > < first line of range info > |working|
  491. X< this area for error messages         > < second line of range info> | icon  |
  492. X<              this line used by sysinfo and for soft key labeling            >
  493. X<              this line used by sysinfo and for soft key labeling            >
  494. X_______________________________________________________________________________
  495. X
  496. X    One problem is that the input area is not very big.  A solution
  497. X    (other than overwriting the first line of the range info) would be
  498. X    to use the scheme that ksh uses to edit the command line (if you
  499. X    get to column 80, a '<' appears there and your command gets shifted
  500. X    to the left.) This way, you could use vi for command line editing.
  501. X    Neat, but it could be more trouble than it's worth, and you would
  502. X    not see long formulas all at once.  Alternatively, the range info
  503. X    could be left where it is and the input area and error messages
  504. X    line extended up to the "working" icon, or the "working" icon
  505. X    suppressed until the line is no longer needed (is this possible
  506. X    without hacking the kernel?)
  507. X
  508. X    Yet another option would be to have a text window pop up when input
  509. X    is required or help text needs to be output.  The range information
  510. X    would stay where it currently is.  This solution would, of course,
  511. X    use real tam windows and thus allow switching from one window to 
  512. X    another if gnuplot were in "text" mode.
  513. X
  514. X    Ideally, when gnuplot exits, it should leave the two bottom lines
  515. X    alone (not clearing them) if what is in them was not written by it.
  516. X
  517. X    Finally, and this is a matter of preference, some people might want
  518. X    gnuplot to clear the screen (the graphics window) or restore the
  519. X    previous contents when exiting.
  520. END_OF_FILE
  521. if test 6524 -ne `wc -c <'README.3B1'`; then
  522.     echo shar: \"'README.3B1'\" unpacked with wrong size!
  523. fi
  524. # end of 'README.3B1'
  525. fi
  526. if test -f 'aed.trm' -a "${1}" != "-c" ; then 
  527.   echo shar: Will not clobber existing file \"'aed.trm'\"
  528. else
  529. echo shar: Extracting \"'aed.trm'\" \(1946 characters\)
  530. sed "s/^X//" >'aed.trm' <<'END_OF_FILE'
  531. X#define AED_XMAX 768
  532. X#define AED_YMAX 575
  533. X
  534. X#define AED_XLAST (AED_XMAX - 1)
  535. X#define AED_YLAST (AED_YMAX - 1)
  536. X
  537. X#define AED_VCHAR    13
  538. X#define AED_HCHAR    8
  539. X#define AED_VTIC    8
  540. X#define AED_HTIC    7
  541. X
  542. X/* slightly different for AED 512 */
  543. X#define AED5_XMAX 512
  544. X#define AED5_XLAST (AED5_XMAX - 1)
  545. X
  546. XAED_init()
  547. X{
  548. X    fprintf(outfile,
  549. X    "\033SEN3DDDN.SEC.7.SCT.0.1.80.80.90.SBC.0.AAV2.MOV.0.9.CHR.0.FFD");
  550. X/*   2            3     4                5     7    6       1
  551. X    1. Clear Screen
  552. X    2. Set Encoding
  553. X    3. Set Default Color
  554. X    4. Set Backround Color Table Entry
  555. X    5. Set Backround Color
  556. X    6. Move to Bottom Lefthand Corner
  557. X    7. Anti-Alias Vectors
  558. X*/
  559. X}
  560. X
  561. X
  562. XAED_graphics()
  563. X{
  564. X    fprintf(outfile,"\033FFD\033");
  565. X}
  566. X
  567. X
  568. XAED_text()
  569. X{
  570. X    fprintf(outfile,"\033MOV.0.9.SEC.7.XXX");
  571. X}
  572. X
  573. X
  574. X
  575. XAED_linetype(linetype)
  576. Xint linetype;
  577. X{
  578. Xstatic int color[2+9] = { 7, 1, 6, 2, 3, 5, 1, 6, 2, 3, 5 };
  579. Xstatic int type[2+9] = { 85, 85, 255, 255, 255, 255, 255, 85, 85, 85, 85 };
  580. X
  581. X    if (linetype >= 10)
  582. X        linetype %= 10;
  583. X    fprintf(outfile,"\033SLS%d.255.",type[linetype+2]);
  584. X    fprintf(outfile,"\033SEC%d.",color[linetype+2]);
  585. X}
  586. X
  587. X
  588. X
  589. XAED_move(x,y)
  590. Xint x,y;
  591. X{
  592. X    fprintf(outfile,"\033MOV%d.%d.",x,y);
  593. X}
  594. X
  595. X
  596. XAED_vector(x,y)
  597. Xint x,y;
  598. X{
  599. X    fprintf(outfile,"\033DVA%d.%d.",x,y);
  600. X}
  601. X
  602. X
  603. XAED_lrput_text(row,str) /* write text to screen while still in graphics mode */
  604. Xint row;
  605. Xchar str[];
  606. X{
  607. X    AED_move(AED_XMAX-((strlen(str)+2)*AED_HCHAR),AED_VTIC+AED_VCHAR*(row+1));
  608. X    fprintf(outfile,"\033XXX%s\033",str);
  609. X}
  610. X
  611. X
  612. XAED5_lrput_text(row,str) /* same, but for AED 512 */
  613. Xint row;
  614. Xchar str[];
  615. X{
  616. X    AED_move(AED5_XMAX-((strlen(str)+2)*AED_HCHAR),AED_VTIC+AED_VCHAR*(row+1));
  617. X    fprintf(outfile,"\033XXX%s\033",str);
  618. X}
  619. X
  620. X
  621. XAED_ulput_text(row,str) /* write text to screen while still in graphics mode */
  622. Xint row;
  623. Xchar str[];
  624. X{
  625. X    AED_move(AED_HTIC*2,AED_YMAX-AED_VTIC-AED_VCHAR*(row+1));
  626. X    fprintf(outfile,"\033XXX%s\033",str);
  627. X}
  628. X
  629. X
  630. X#define hxt (AED_HTIC/2)
  631. X#define hyt (AED_VTIC/2)
  632. X
  633. XAED_reset()
  634. X{
  635. X    fprintf(outfile,"\033SCT0.1.0.0.0.SBC.0.FFD");
  636. X}
  637. X
  638. X
  639. END_OF_FILE
  640. if test 1946 -ne `wc -c <'aed.trm'`; then
  641.     echo shar: \"'aed.trm'\" unpacked with wrong size!
  642. fi
  643. # end of 'aed.trm'
  644. fi
  645. if test -f 'bitgraph.trm' -a "${1}" != "-c" ; then 
  646.   echo shar: Will not clobber existing file \"'bitgraph.trm'\"
  647. else
  648. echo shar: Extracting \"'bitgraph.trm'\" \(1025 characters\)
  649. sed "s/^X//" >'bitgraph.trm' <<'END_OF_FILE'
  650. X/* thanks to dukecdu!evs (Ed Simpson) for the BBN BitGraph driver */
  651. X#define BG_XMAX                 768 /* width of plot area */
  652. X#define BG_YMAX                 768 /* height of plot area */
  653. X#define BG_SCREEN_HEIGHT    1024 /* full screen height */
  654. X
  655. X#define BG_XLAST     (BG_XMAX - 1)
  656. X#define BG_YLAST     (BG_YMAX - 1)
  657. X
  658. X#define BG_VCHAR    16
  659. X#define BG_HCHAR     9
  660. X#define BG_VTIC         8
  661. X#define BG_HTIC         8    
  662. X
  663. X
  664. X#define BG_init TEK40init
  665. X
  666. X#define BG_graphics TEK40graphics
  667. X
  668. X
  669. X#define BG_linetype TEK40linetype
  670. X
  671. X#define BG_move TEK40move
  672. X
  673. X#define BG_vector TEK40vector
  674. X
  675. X
  676. XBG_text()
  677. X{
  678. X    BG_move(0, BG_SCREEN_HEIGHT - 2 * BG_VCHAR);
  679. X    fprintf(outfile,"\037");
  680. X/*                   1
  681. X    1. into alphanumerics
  682. X*/
  683. X}
  684. X
  685. X
  686. XBG_lrput_text(row,str)
  687. Xunsigned int row;
  688. Xchar str[];
  689. X{
  690. X    BG_move(BG_XMAX - BG_HTIC - BG_HCHAR*(strlen(str)+1),
  691. X        BG_VTIC + BG_VCHAR*(row+1));
  692. X    fprintf(outfile,"\037%s\n",str);
  693. X}
  694. X
  695. X
  696. XBG_ulput_text(row,str)
  697. Xunsigned int row;
  698. Xchar str[];
  699. X{
  700. X    BG_move(BG_HTIC, BG_YMAX - BG_VTIC - BG_VCHAR*(row+1));
  701. X    fprintf(outfile,"\037%s\n",str);
  702. X}
  703. X
  704. X
  705. X#define BG_reset TEK40reset
  706. X
  707. X
  708. END_OF_FILE
  709. if test 1025 -ne `wc -c <'bitgraph.trm'`; then
  710.     echo shar: \"'bitgraph.trm'\" unpacked with wrong size!
  711. fi
  712. # end of 'bitgraph.trm'
  713. fi
  714. if test -f 'command.c' -a "${1}" != "-c" ; then 
  715.   echo shar: Will not clobber existing file \"'command.c'\"
  716. else
  717. echo shar: Extracting \"'command.c'\" \(23912 characters\)
  718. sed "s/^X//" >'command.c' <<'END_OF_FILE'
  719. X/*
  720. X *
  721. X *    G N U P L O T  --  command.c
  722. X *
  723. X *  Copyright (C) 1986, 1987  Thomas Williams, Colin Kelley
  724. X *
  725. X *  You may use this code as you wish if credit is given and this message
  726. X *  is retained.
  727. X *
  728. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  729. X *  included in later releases.
  730. X *
  731. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  732. X */
  733. X
  734. X#include <stdio.h>
  735. X#include <math.h>
  736. X
  737. X#ifdef MSDOS
  738. X#include <process.h>
  739. X#endif
  740. X
  741. X#include "plot.h"
  742. X
  743. X#ifndef STDOUT
  744. X#define STDOUT 1
  745. X#endif
  746. X
  747. X/*
  748. X * global variables to hold status of 'set' options
  749. X *
  750. X */
  751. XBOOLEAN            polar        = FALSE; 
  752. XBOOLEAN            autoscale    = TRUE;
  753. Xchar            dummy_var[MAX_ID_LEN+1] = "x";
  754. Xenum PLOT_STYLE data_style    = POINTS,
  755. X                func_style    = LINES;
  756. XBOOLEAN            log_x        = FALSE,
  757. X                log_y        = FALSE;
  758. XFILE*            outfile;
  759. Xchar            outstr[MAX_ID_LEN+1] = "STDOUT";
  760. Xint                samples        = SAMPLES;
  761. Xint                term        = 0;                /* unknown term is 0 */
  762. Xdouble            xmin        = -10.0,
  763. X                xmax        = 10.0,
  764. X                ymin        = -10.0,
  765. X                ymax        = 10.0;
  766. Xdouble            loff        = 0.0,
  767. X                roff        = 0.0,
  768. X                toff        = 0.0,
  769. X                boff        = 0.0;
  770. Xdouble            zero = ZERO;            /* zero threshold, not 0! */
  771. X
  772. X
  773. XBOOLEAN screen_ok;
  774. XBOOLEAN term_init;
  775. XBOOLEAN undefined;
  776. X
  777. X/*
  778. X * instead of <strings.h>
  779. X */
  780. X
  781. Xchar *gets(),*getenv();
  782. Xchar *strcpy(),*strncpy(),*strcat();
  783. X
  784. Xchar *malloc();
  785. X
  786. Xdouble magnitude(),angle(),real(),imag();
  787. Xstruct value *const_express(), *pop(), *complex();
  788. Xstruct at_type *temp_at(), *perm_at();
  789. Xstruct udft_entry *add_udf();
  790. Xstruct udvt_entry *add_udv();
  791. X
  792. Xextern struct termentry term_tbl[];
  793. X
  794. Xstruct lexical_unit token[MAX_TOKENS];
  795. Xchar input_line[MAX_LINE_LEN+1] = "set term ";
  796. Xchar c_dummy_var[MAX_ID_LEN+1];         /* current dummy var */
  797. Xint num_tokens, c_token;
  798. X
  799. Xstruct curve_points *first_plot = NULL;
  800. Xstruct udft_entry plot_func, *dummy_func;
  801. X
  802. Xstatic char replot_line[MAX_LINE_LEN+1];
  803. Xstatic int plot_token;                    /* start of 'plot' command */
  804. Xstatic char help[MAX_LINE_LEN] = HELP;
  805. X
  806. Xcom_line()
  807. X{
  808. X    read_line();
  809. X
  810. X    screen_ok = TRUE; /* so we can flag any new output */
  811. X
  812. X    do_line();
  813. X}
  814. X
  815. X
  816. Xdo_line()      /* also used in load_file */
  817. X{
  818. X    if (is_comment(input_line[0]))
  819. X        return;
  820. X    if (is_system(input_line[0])) {
  821. X        do_system();
  822. X        fputs("!\n",stderr);
  823. X        return;
  824. X    }
  825. X    num_tokens = scanner(input_line);
  826. X    c_token = 0;
  827. X    while(c_token < num_tokens) {
  828. X        command();
  829. X        if (c_token < num_tokens)    /* something after command */
  830. X            if (equals(c_token,";"))
  831. X                c_token++;
  832. X            else
  833. X                    int_error("';' expected",c_token);
  834. X    }
  835. X}
  836. X
  837. X
  838. X
  839. Xcommand()
  840. X{
  841. Xstatic char sv_file[MAX_LINE_LEN+1];
  842. X            /* string holding name of save or load file */
  843. X
  844. X    c_dummy_var[0] = '\0';        /* no dummy variable */
  845. X
  846. X    if (is_definition(c_token))
  847. X        define();
  848. X    else if (equals(c_token,"help") || equals(c_token,"?")) {
  849. X        register int len;
  850. X        register char *help_ptr;
  851. X
  852. X        c_token++;
  853. X        if ((help_ptr = getenv("GNUHELP")))    /* initial command */
  854. X            (void) strncpy(help,help_ptr,sizeof(help) - 1);
  855. X        else
  856. X            (void) strncpy(help,HELP,sizeof(help) - 1);
  857. X
  858. X        while (!(END_OF_COMMAND)) {
  859. X            len = strlen(help);
  860. X            help[len] = ' ';   /* put blank between help segments */
  861. X            copy_str(help+len+1,c_token++);
  862. X        }
  863. X        do_help();
  864. X        screen_ok = FALSE;
  865. X        c_token++;
  866. X    }
  867. X    else if (almost_equals(c_token,"pa$use")) {
  868. X        struct value a;
  869. X        int stime, text=0, len;
  870. X        char buf[MAX_LINE_LEN+1], *ptr;
  871. X
  872. X        c_token++;
  873. X        stime = (int )real(const_express(&a));
  874. X        if (!(END_OF_COMMAND)) {
  875. X            if (!isstring(c_token))
  876. X                int_error("expecting string",c_token);
  877. X            else {
  878. X            /*    Unfortunately, quote_str has a ID limit. */
  879. X                len = token[c_token].length - 2;
  880. X                ptr = &input_line[token[c_token].start_index+1];
  881. X                fprintf (stderr, "%.*s", len,ptr);
  882. X                text = 1;
  883. X            }
  884. X        }
  885. X        if (stime < 0) fgets (buf,MAX_LINE_LEN,stdin);  /* Hold until CR hit. */
  886. X        if (stime > 0) sleep(stime);
  887. X        if (text != 0 && stime >= 0) fprintf (stderr,"\n");
  888. X        c_token++;
  889. X        screen_ok = FALSE;
  890. X    }
  891. X    else if (almost_equals(c_token,"pr$int")) {
  892. X        struct value a;
  893. X
  894. X        c_token++;
  895. X        (void) const_express(&a);
  896. X        (void) putc('\t',stderr);
  897. X        disp_value(stderr,&a);
  898. X        (void) putc('\n',stderr);
  899. X        screen_ok = FALSE;
  900. X    }
  901. X    else if (almost_equals(c_token,"p$lot")) {
  902. X        plot_token = c_token++;
  903. X        plotrequest();
  904. X    }
  905. X    else if (almost_equals(c_token,"rep$lot")) {
  906. X        if (replot_line[0] == '\0') 
  907. X            int_error("no previous plot",c_token);
  908. X        (void) strcpy(input_line,replot_line);
  909. X        screen_ok = FALSE;
  910. X        num_tokens = scanner(input_line);
  911. X        c_token = 1;                    /* skip the 'plot' part */
  912. X        plotrequest();
  913. X    }
  914. X    else if (almost_equals(c_token,"se$t"))
  915. X        set_stuff();
  916. X    else if (almost_equals(c_token,"sh$ow"))
  917. X        show_stuff();
  918. X    else if (almost_equals(c_token,"cl$ear")) {
  919. X        if (!term_init) {
  920. X            (*term_tbl[term].init)();
  921. X            term_init = TRUE;
  922. X        }
  923. X        (*term_tbl[term].graphics)();
  924. X        (*term_tbl[term].text)();
  925. X        (void) fflush(outfile);
  926. X        screen_ok = FALSE;
  927. X        c_token++;
  928. X    }
  929. X    else if (almost_equals(c_token,"she$ll")) {
  930. X        do_shell();
  931. X        screen_ok = FALSE;
  932. X        c_token++;
  933. X    }
  934. X    else if (almost_equals(c_token,"sa$ve")) {
  935. X        if (almost_equals(++c_token,"f$unctions")) {
  936. X            if (!isstring(++c_token))
  937. X                int_error("expecting filename",c_token);
  938. X            else {
  939. X                quote_str(sv_file,c_token);
  940. X                save_functions(fopen(sv_file,"w"));
  941. X            }
  942. X        }
  943. X        else if (almost_equals(c_token,"v$ariables")) {
  944. X            if (!isstring(++c_token))
  945. X                int_error("expecting filename",c_token);
  946. X            else {
  947. X                quote_str(sv_file,c_token);
  948. X                save_variables(fopen(sv_file,"w"));
  949. X            }
  950. X        }
  951. X        else if (isstring(c_token)) {
  952. X            quote_str(sv_file,c_token);
  953. X            save_all(fopen(sv_file,"w"));
  954. X        }
  955. X        else {
  956. X            int_error(
  957. X        "filename or keyword 'functions' or 'variables' expected",c_token);
  958. X        }
  959. X        c_token++;
  960. X    }
  961. X    else if (almost_equals(c_token,"l$oad")) {
  962. X        if (!isstring(++c_token))
  963. X            int_error("expecting filename",c_token);
  964. X        else {
  965. X            quote_str(sv_file,c_token);
  966. X            load_file(fopen(sv_file,"r"));    
  967. X        /* input_line[] and token[] now destroyed! */
  968. X            c_token = num_tokens = 0;
  969. X        }
  970. X    }
  971. X    else if (almost_equals(c_token,"ex$it") ||
  972. X            almost_equals(c_token,"q$uit")) {
  973. X        done(IO_SUCCESS);
  974. X    }
  975. X    else if (!equals(c_token,";")) {        /* null statement */
  976. X        int_error("invalid command",c_token);
  977. X    }
  978. X}
  979. X
  980. X
  981. Xenum PLOT_STYLE
  982. Xget_style()
  983. X{
  984. Xregister enum PLOT_STYLE ps;
  985. X
  986. X    c_token++;
  987. X    if (almost_equals(c_token,"l$ines"))
  988. X        ps = LINES;
  989. X    else if (almost_equals(c_token,"i$mpulses"))
  990. X        ps = IMPULSES;
  991. X    else if (almost_equals(c_token,"p$oints"))
  992. X        ps = POINTS;
  993. X    else
  994. X        int_error("expecting 'lines', 'points', or 'impulses'",c_token);
  995. X    c_token++;
  996. X    return(ps);
  997. X}
  998. X
  999. X
  1000. Xset_stuff()
  1001. X{
  1002. Xstatic char testfile[MAX_LINE_LEN+1];
  1003. X
  1004. X    if (almost_equals(++c_token,"a$utoscale")) {
  1005. X        autoscale = TRUE;
  1006. X        c_token++;
  1007. X    }
  1008. X    else if (almost_equals(c_token,"noa$utoscale")) {
  1009. X        autoscale = FALSE;
  1010. X        c_token++;
  1011. X    }
  1012. X    else if (almost_equals(c_token,"po$lar")) {
  1013. X        polar = TRUE;
  1014. X        xmin = 0.0;
  1015. X        xmax = 2*Pi;
  1016. X        c_token++;
  1017. X    }
  1018. X    else if (almost_equals(c_token,"nopo$lar")) {
  1019. X        polar = FALSE;
  1020. X        xmin = -10.0;
  1021. X        xmax = 10.0;
  1022. X        c_token++;
  1023. X    }
  1024. X    else if (almost_equals(c_token,"d$ata")) {
  1025. X        c_token++;
  1026. X        if (!almost_equals(c_token,"s$tyle"))
  1027. X            int_error("expecting keyword 'style'",c_token);
  1028. X        data_style = get_style();
  1029. X    }
  1030. X    else if (almost_equals(c_token,"d$ummy")) {
  1031. X        c_token++;
  1032. X        copy_str(dummy_var,c_token++);
  1033. X    }
  1034. X    else if (almost_equals(c_token,"f$unction")) {
  1035. X        c_token++;
  1036. X        if (!almost_equals(c_token,"s$tyle"))
  1037. X            int_error("expecting keyword 'style'",c_token);
  1038. X        func_style = get_style();
  1039. X    }
  1040. X    else if (almost_equals(c_token,"l$ogscale")) {
  1041. X        c_token++;
  1042. X        if (equals(c_token,"x")) {
  1043. X            log_y = FALSE;
  1044. X            log_x = TRUE;
  1045. X            c_token++;
  1046. X        }
  1047. X        else if (equals(c_token,"y")) {
  1048. X            log_x = FALSE;
  1049. X            log_y = TRUE;
  1050. X            c_token++;
  1051. X        }
  1052. X        else if (equals(c_token,"xy") || equals(c_token,"yx")) {
  1053. X            log_x = log_y = TRUE;
  1054. X            c_token++;
  1055. X        }
  1056. X        else
  1057. X            int_error("expecting 'x', 'y', or 'xy'",c_token);
  1058. X    }
  1059. X    else if (almost_equals(c_token,"nol$ogscale")) {
  1060. X        log_x = log_y = FALSE;
  1061. X        c_token++;
  1062. X    }
  1063. X    else if (almost_equals(c_token,"of$fsets")) {
  1064. X        c_token++;
  1065. X        if (END_OF_COMMAND) {
  1066. X            loff = roff = toff = boff = 0.0;  /* Reset offsets */
  1067. X        }
  1068. X        else {
  1069. X            load_offsets (&loff,&roff,&toff,&boff);
  1070. X        }
  1071. X    }
  1072. X    else if (almost_equals(c_token,"o$utput")) {
  1073. X        register FILE *f;
  1074. X
  1075. X        c_token++;
  1076. X        if (END_OF_COMMAND) {    /* no file specified */
  1077. X             UP_redirect (4);
  1078. X#ifdef VMS
  1079. X            if (outfile != stdout) /* Never close stdout */
  1080. X#endif
  1081. X            (void) fclose(outfile);
  1082. X#ifdef VMS
  1083. X            outfile = stdout; /* Avoid the dup... */
  1084. X#else
  1085. X            outfile = fdopen(dup(STDOUT), "w");
  1086. X#endif
  1087. X            term_init = FALSE;
  1088. X            (void) strcpy(outstr,"STDOUT");
  1089. X        } else if (!isstring(c_token))
  1090. X            int_error("expecting filename",c_token);
  1091. X        else {
  1092. X            quote_str(testfile,c_token);
  1093. X            if (!(f = fopen(testfile,"w"))) {
  1094. X              os_error("cannot open file; output not changed",c_token);
  1095. X            }
  1096. X#ifdef VMS
  1097. X            if (outfile != stdout) /* Never close stdout */
  1098. X#endif
  1099. X            (void) fclose(outfile);
  1100. X            outfile = f;
  1101. X            term_init = FALSE;
  1102. X            outstr[0] = '\'';
  1103. X            (void) strcat(strcpy(outstr+1,testfile),"'");
  1104. X             UP_redirect (1);
  1105. X        }
  1106. X        c_token++;
  1107. X    }
  1108. X    else if (almost_equals(c_token,"sa$mples")) {
  1109. X        register int tsamp;
  1110. X        struct value a;
  1111. X
  1112. X        c_token++;
  1113. X        tsamp = (int)magnitude(const_express(&a));
  1114. X        if (tsamp < 1)
  1115. X            int_error("sampling rate must be > 0; sampling unchanged",
  1116. X                c_token);
  1117. X        else {
  1118. X            register struct curve_points *f_p = first_plot;
  1119. X
  1120. X            first_plot = NULL;
  1121. X            cp_free(f_p);
  1122. X            samples = tsamp;
  1123. X        }
  1124. X    }
  1125. X    else if (almost_equals(c_token,"t$erminal")) {
  1126. X        c_token++;
  1127. X        if (END_OF_COMMAND) {
  1128. X            list_terms();
  1129. X            screen_ok = FALSE;
  1130. X        }
  1131. X        else
  1132. X            term = set_term(c_token);
  1133. X        c_token++;
  1134. X    }
  1135. X    else if (almost_equals(c_token,"x$range")) {
  1136. X        c_token++;
  1137. X        if (!equals(c_token,"["))
  1138. X            int_error("expecting '['",c_token);
  1139. X        c_token++;
  1140. X        load_range(&xmin,&xmax);
  1141. X        if (!equals(c_token,"]"))
  1142. X            int_error("expecting ']'",c_token);
  1143. X        c_token++;
  1144. X    }
  1145. X    else if (almost_equals(c_token,"y$range")) {
  1146. X        c_token++;
  1147. X        if (!equals(c_token,"["))
  1148. X            int_error("expecting '['",c_token);
  1149. X        c_token++;
  1150. X        load_range(&ymin,&ymax);
  1151. X        autoscale = FALSE;
  1152. X        if (!equals(c_token,"]"))
  1153. X            int_error("expecting ']'",c_token);
  1154. X        c_token++;
  1155. X    }
  1156. X    else if (almost_equals(c_token,"z$ero")) {
  1157. X        struct value a;
  1158. X        c_token++;
  1159. X        zero = magnitude(const_express(&a));
  1160. X    }
  1161. X    else
  1162. X        int_error(
  1163. X    "valid set options:  '[no]autoscale', 'data', 'dummy', 'function',\n\
  1164. X'[no]logscale', 'offsets', 'output', '[no]polar', 'samples',\n\
  1165. X'terminal', 'xrange', 'yrange', 'zero'",
  1166. X    c_token);
  1167. X}
  1168. X
  1169. X
  1170. Xshow_stuff()
  1171. X{
  1172. X    if (almost_equals(++c_token,"ac$tion_table") ||
  1173. X             equals(c_token,"at") ) {
  1174. X        c_token++;
  1175. X        show_at();
  1176. X        c_token++;
  1177. X    }
  1178. X    else if (almost_equals(c_token,"au$toscale")) {
  1179. X        (void) putc('\n',stderr);
  1180. X        show_autoscale();
  1181. X        c_token++;
  1182. X    }
  1183. X    else if (almost_equals(c_token,"d$ata")) {
  1184. X        c_token++;
  1185. X        if (!almost_equals(c_token,"s$tyle"))
  1186. X            int_error("expecting keyword 'style'",c_token);
  1187. X        (void) putc('\n',stderr);
  1188. X        show_style("data",data_style);
  1189. X        c_token++;
  1190. X    }
  1191. X    else if (almost_equals(c_token,"d$ummy")) {
  1192. X        fprintf(stderr,"\n\tdummy variable is %s\n",dummy_var);
  1193. X        c_token++;
  1194. X    }
  1195. X    else if (almost_equals(c_token,"f$unctions")) {
  1196. X        c_token++;
  1197. X        if (almost_equals(c_token,"s$tyle"))  {
  1198. X            (void) putc('\n',stderr);
  1199. X            show_style("functions",func_style);
  1200. X            c_token++;
  1201. X        }
  1202. X        else
  1203. X            show_functions();
  1204. X    }
  1205. X    else if (almost_equals(c_token,"l$ogscale")) {
  1206. X        (void) putc('\n',stderr);
  1207. X        show_logscale();
  1208. X        c_token++;
  1209. X    }
  1210. X    else if (almost_equals(c_token,"of$fsets")) {
  1211. X        (void) putc('\n',stderr);
  1212. X        show_offsets();
  1213. X        c_token++;
  1214. X    }
  1215. X    else if (almost_equals(c_token,"o$utput")) {
  1216. X        (void) putc('\n',stderr);
  1217. X        show_output();
  1218. X        c_token++;
  1219. X    }
  1220. X    else if (almost_equals(c_token,"po$lar")) {
  1221. X        (void) putc('\n',stderr);
  1222. X        show_polar();
  1223. X        c_token++;
  1224. X    }
  1225. X    else if (almost_equals(c_token,"sa$mples")) {
  1226. X        (void) putc('\n',stderr);
  1227. X        show_samples();
  1228. X        c_token++;
  1229. X    }
  1230. X    else if (almost_equals(c_token,"t$erminal")) {
  1231. X        (void) putc('\n',stderr);
  1232. X        show_term();
  1233. X        c_token++;
  1234. X    }
  1235. X    else if (almost_equals(c_token,"v$ariables")) {
  1236. X        show_variables();
  1237. X        c_token++;
  1238. X    }
  1239. X    else if (almost_equals(c_token,"ve$rsion")) {
  1240. X        show_version();
  1241. X        c_token++;
  1242. X    }
  1243. X    else if (almost_equals(c_token,"x$range")) {
  1244. X        (void) putc('\n',stderr);
  1245. X        show_range('x',xmin,xmax);
  1246. X        c_token++;
  1247. X    }
  1248. X    else if (almost_equals(c_token,"y$range")) {
  1249. X        (void) putc('\n',stderr);
  1250. X        show_range('y',ymin,ymax);
  1251. X        c_token++;
  1252. X    }
  1253. X    else if (almost_equals(c_token,"z$ero")) {
  1254. X        (void) putc('\n',stderr);
  1255. X        show_zero();
  1256. X        c_token++;
  1257. X    }
  1258. X    else if (almost_equals(c_token,"a$ll")) {
  1259. X        c_token++;
  1260. X        show_version();
  1261. X        show_polar();
  1262. X        fprintf(stderr,"\tdummy variable is %s\n",dummy_var);
  1263. X        show_style("data",data_style);
  1264. X        show_style("functions",func_style);
  1265. X        show_output();
  1266. X        show_term();
  1267. X        show_samples();
  1268. X        show_logscale();
  1269. X        show_autoscale();
  1270. X        show_zero();
  1271. X        show_range('x',xmin,xmax);
  1272. X        show_range('y',ymin,ymax);
  1273. X        show_offsets();
  1274. X        show_variables();
  1275. X        show_functions();
  1276. X        c_token++;
  1277. X    }
  1278. X    else
  1279. X        int_error(
  1280. X    "valid show options:  'action_table', 'all', 'autoscale', 'data',\n\
  1281. X'dummy', 'function', 'logscale', 'offsets', 'output', 'polar',\n\
  1282. X'samples', 'terminal', 'variables', 'version', 'xrange', 'yrange', 'zero'",
  1283. Xc_token);
  1284. X    screen_ok = FALSE;
  1285. X    (void) putc('\n',stderr);
  1286. X}
  1287. X
  1288. X
  1289. Xload_offsets (a, b, c, d)
  1290. Xdouble *a,*b, *c, *d;
  1291. X{
  1292. Xstruct value t;
  1293. X
  1294. X    *a = real (const_express(&t));  /* loff value */
  1295. X    c_token++;
  1296. X    if (equals(c_token,","))
  1297. X        c_token++;
  1298. X    if (END_OF_COMMAND) 
  1299. X        return;
  1300. X
  1301. X    *b = real (const_express(&t));  /* roff value */
  1302. X    c_token++;
  1303. X    if (equals(c_token,","))
  1304. X        c_token++;
  1305. X    if (END_OF_COMMAND) 
  1306. X        return;
  1307. X
  1308. X    *c = real (const_express(&t));  /* toff value */
  1309. X    c_token++;
  1310. X    if (equals(c_token,","))
  1311. X        c_token++;
  1312. X    if (END_OF_COMMAND) 
  1313. X        return;
  1314. X
  1315. X    *d = real (const_express(&t));  /* boff value */
  1316. X    c_token++;
  1317. X}
  1318. X
  1319. X
  1320. Xload_range(a,b)
  1321. Xdouble *a,*b;
  1322. X{
  1323. Xstruct value t;
  1324. X
  1325. X    if (equals(c_token,"]"))
  1326. X        return;
  1327. X    if (END_OF_COMMAND) {
  1328. X        int_error("starting range value or ':' expected",c_token);
  1329. X    } else if (!equals(c_token,"to") && !equals(c_token,":"))  {
  1330. X        *a = real(const_express(&t));
  1331. X    }    
  1332. X    if (!equals(c_token,"to") && !equals(c_token,":"))
  1333. X        int_error("':' expected",c_token);
  1334. X    c_token++;
  1335. X    if (!equals(c_token,"]"))
  1336. X        *b = real(const_express(&t));
  1337. X}
  1338. X
  1339. X
  1340. Xplotrequest()
  1341. X{
  1342. X    
  1343. X    if (!term)                    /* unknown */
  1344. X        int_error("use 'set term' to set terminal type first",c_token);
  1345. X
  1346. X    if (equals(c_token,"[")) {
  1347. X        c_token++;
  1348. X        if (isletter(c_token)) {
  1349. X            copy_str(c_dummy_var,c_token++);
  1350. X            if (equals(c_token,"="))
  1351. X                c_token++;
  1352. X            else
  1353. X                int_error("'=' expected",c_token);
  1354. X        }
  1355. X        load_range(&xmin,&xmax);
  1356. X        if (!equals(c_token,"]"))
  1357. X            int_error("']' expected",c_token);
  1358. X        c_token++;
  1359. X    }
  1360. X
  1361. X    if (equals(c_token,"[")) { /* set optional y ranges */
  1362. X        c_token++;
  1363. X        load_range(&ymin,&ymax);
  1364. X        autoscale = FALSE;
  1365. X        if (!equals(c_token,"]"))
  1366. X            int_error("']' expected",c_token);
  1367. X        c_token++;
  1368. X    }
  1369. X
  1370. X    eval_plots();
  1371. X}
  1372. X
  1373. X
  1374. Xdefine()
  1375. X{
  1376. Xregister int start_token;  /* the 1st token in the function definition */
  1377. Xregister struct udvt_entry *udv;
  1378. Xregister struct udft_entry *udf;
  1379. X
  1380. X    if (equals(c_token+1,"(")) {
  1381. X        /* function ! */
  1382. X        start_token = c_token;
  1383. X        copy_str(c_dummy_var, c_token + 2);
  1384. X        c_token += 5; /* skip (, dummy, ) and = */
  1385. X        if (END_OF_COMMAND)
  1386. X            int_error("function definition expected",c_token);
  1387. X        udf = dummy_func = add_udf(start_token);
  1388. X        if (udf->at)                /* already a dynamic a.t. there */
  1389. X            free((char *)udf->at);    /* so free it first */
  1390. X        if (!(udf->at = perm_at()))
  1391. X            int_error("not enough memory for function",start_token);
  1392. X        m_capture(&(udf->definition),start_token,c_token-1);
  1393. X    }
  1394. X    else {
  1395. X        /* variable ! */
  1396. X        start_token = c_token;
  1397. X        c_token +=2;
  1398. X        udv = add_udv(start_token);
  1399. X        (void) const_express(&(udv->udv_value));
  1400. X        udv->udv_undef = FALSE;
  1401. X    }
  1402. X}
  1403. X
  1404. X
  1405. Xget_data(this_plot)
  1406. Xstruct curve_points *this_plot;
  1407. X{
  1408. Xstatic char data_file[MAX_LINE_LEN+1], line[MAX_LINE_LEN+1];
  1409. Xregister int i, overflow, l_num;
  1410. Xregister FILE *fp;
  1411. Xfloat x, y;
  1412. X
  1413. X    quote_str(data_file, c_token);
  1414. X    this_plot->plot_type = DATA;
  1415. X    if (!(fp = fopen(data_file, "r")))
  1416. X        os_error("can't open data file", c_token);
  1417. X
  1418. X    l_num = 0;
  1419. X
  1420. X    overflow = i = 0;
  1421. X
  1422. X    while (fgets(line, MAX_LINE_LEN, fp)) {
  1423. X        l_num++;
  1424. X        if (is_comment(line[0]) || ! line[1])    /* line[0] will be '\n' */
  1425. X            continue;        /* ignore comments  and blank lines */
  1426. X
  1427. X        if (i == samples+1) {
  1428. X            overflow = i;    /* keep track for error message later */
  1429. X            i--;            /* so we don't fall off end of points[i] */
  1430. X        }
  1431. X        switch (sscanf(line, "%f %f", &x, &y)) {
  1432. X            case 1:            /* only one number on the line */
  1433. X                y = x;        /* so use it as the y value, */
  1434. X                x = i;        /* and use the index as the x */
  1435. X            /* no break; !!! */
  1436. X            case 2:
  1437. X                this_plot->points[i].undefined = TRUE;
  1438. X                if (x >= xmin && x <= xmax && (autoscale ||
  1439. X                    (y >= ymin && y <= ymax))) {
  1440. X                    if (log_x) {
  1441. X                        if (x <= 0.0)
  1442. X                            break;
  1443. X                        this_plot->points[i].x = log10(x);
  1444. X                    } else
  1445. X                        this_plot->points[i].x = x;
  1446. X                    if (log_y) {
  1447. X                        if (y <= 0.0)
  1448. X                            break;
  1449. X                        this_plot->points[i].y = log10(y);
  1450. X                    } else
  1451. X                        this_plot->points[i].y = y;
  1452. X                    if (autoscale) {
  1453. X                        if (y < ymin) ymin = y;
  1454. X                        if (y > ymax) ymax = y;
  1455. X                    }
  1456. X
  1457. X                    this_plot->points[i].undefined = FALSE;
  1458. X                }
  1459. X                if (overflow)
  1460. X                    overflow++;
  1461. X                else
  1462. X                    i++;
  1463. X                break;
  1464. X
  1465. X            default:
  1466. X                (void) sprintf(line, "bad data on line %d", l_num);
  1467. X                int_error(line,c_token);
  1468. X        }
  1469. X    }
  1470. X    if (overflow) {
  1471. X        (void) sprintf(line,
  1472. X    "%d data points found--samples must be set at least this high",overflow);
  1473. X                /* actually, samples can be one less! */
  1474. X        int_error(line,c_token);
  1475. X    }
  1476. X    this_plot->p_count = i;
  1477. X    (void) fclose(fp);
  1478. X}
  1479. X
  1480. X
  1481. Xeval_plots()
  1482. X{
  1483. Xregister int i;
  1484. Xregister struct curve_points *this_plot, **tp_ptr;
  1485. Xregister int start_token, mysamples;
  1486. Xregister double x_min, x_max, y_min, y_max, x;
  1487. Xregister double xdiff, temp;
  1488. Xregister int plot_num;
  1489. Xstatic struct value a;
  1490. X
  1491. X    /* don't sample higher than output device can handle! */
  1492. X    mysamples = (samples <= term_tbl[term].xmax) ?samples :term_tbl[term].xmax;
  1493. X
  1494. X    if (log_x) {
  1495. X        if (xmin < 0.0 || xmax < 0.0)
  1496. X            int_error("x range must be above 0 for log scale!",NO_CARET);
  1497. X        x_min = log10(xmin);
  1498. X        x_max = log10(xmax);
  1499. X    } else {
  1500. X        x_min = xmin;
  1501. X        x_max = xmax;
  1502. X    }
  1503. X
  1504. X    if (autoscale) {
  1505. X        ymin = HUGE;
  1506. X        ymax = -HUGE;
  1507. X    } else if (log_y && (ymin <= 0.0 || ymax <= 0.0))
  1508. X            int_error("y range must be above 0 for log scale!",
  1509. X                NO_CARET);
  1510. X
  1511. X    xdiff = (x_max - x_min) / mysamples;
  1512. X
  1513. X    tp_ptr = &(first_plot);
  1514. X    plot_num = 0;
  1515. X
  1516. X    while (TRUE) {
  1517. X        if (END_OF_COMMAND)
  1518. X            int_error("function to plot expected",c_token);
  1519. X
  1520. X        start_token = c_token;
  1521. X
  1522. X        if (is_definition(c_token)) {
  1523. X            define();
  1524. X        } else {
  1525. X            plot_num++;
  1526. X            if (*tp_ptr)
  1527. X                this_plot = *tp_ptr;
  1528. X            else {        /* no memory malloc()'d there yet */
  1529. X                this_plot = (struct curve_points *)
  1530. X                    malloc((unsigned int) (sizeof(struct curve_points) -
  1531. X                    (MAX_POINTS - (samples+1))*sizeof(struct coordinate)));
  1532. X                if (!this_plot)
  1533. X                    int_error("out of memory",c_token);
  1534. X                this_plot->next_cp = NULL;
  1535. X                this_plot->title = NULL;
  1536. X                *tp_ptr = this_plot;
  1537. X            }
  1538. X
  1539. X            if (isstring(c_token)) {            /* data file to plot */
  1540. X                this_plot->plot_type = DATA;
  1541. X                this_plot->plot_style = data_style;
  1542. X                get_data(this_plot);
  1543. X                c_token++;
  1544. X            }
  1545. X            else {                            /* function to plot */
  1546. X                this_plot->plot_type = FUNC;
  1547. X                this_plot->plot_style = func_style;
  1548. X
  1549. X                (void) strcpy(c_dummy_var,dummy_var);
  1550. X                dummy_func = &plot_func;
  1551. X
  1552. X                plot_func.at = temp_at();
  1553. X
  1554. X                for (i = 0; i <= mysamples; i++) {
  1555. X                    if (i == samples+1)
  1556. X                        int_error("number of points exceeded samples",
  1557. X                            NO_CARET);
  1558. X                    x = x_min + i*xdiff;
  1559. X                    if (log_x)
  1560. X                        x = pow(10.0,x);
  1561. X                    (void) complex(&plot_func.dummy_value, x, 0.0);
  1562. X                    
  1563. X                    evaluate_at(plot_func.at,&a);
  1564. X
  1565. X                    if (this_plot->points[i].undefined =
  1566. X                        undefined || (fabs(imag(&a)) > zero))
  1567. X                            continue;
  1568. X                /*    
  1569. X                    The old code used plot_type to generate x, but with
  1570. X                    polar and offset concepts we need to record the x
  1571. X                    value.
  1572. X                */
  1573. X                    this_plot->points[i].x = x;
  1574. X
  1575. X                    temp = real(&a);
  1576. X
  1577. X                    if (log_y && temp <= 0.0) {
  1578. X                            this_plot->points[i].undefined = TRUE;
  1579. X                            continue;
  1580. X                    }
  1581. X                    if (autoscale) {
  1582. X                        if (temp < ymin) ymin = temp;
  1583. X                        if (temp > ymax) ymax = temp;
  1584. X                    } else if (temp < ymin || temp > ymax) {
  1585. X                        this_plot->points[i].undefined = TRUE;
  1586. X                        continue;
  1587. X                    }
  1588. X
  1589. X                    this_plot->points[i].y = log_y ? log10(temp) : temp;
  1590. X                }
  1591. X                this_plot->p_count = i; /* mysamples + 1 */
  1592. X            }
  1593. X            m_capture(&(this_plot->title),start_token,c_token-1);
  1594. X            if (almost_equals(c_token,"w$ith"))
  1595. X                this_plot->plot_style = get_style();
  1596. X            tp_ptr = &(this_plot->next_cp);
  1597. X        }
  1598. X
  1599. X        if (equals(c_token,","))
  1600. X            c_token++;
  1601. X        else
  1602. X            break;
  1603. X    }
  1604. X
  1605. X    if (autoscale && (ymin == ymax))
  1606. X        ymax += 1.0;    /* kludge to avoid divide-by-zero in do_plot */
  1607. X
  1608. X    if (log_y) {
  1609. X        y_min = log10(ymin);
  1610. X        y_max = log10(ymax);
  1611. X    } else {
  1612. X        y_min = ymin;
  1613. X        y_max = ymax;
  1614. X    }
  1615. X    capture(replot_line,plot_token,c_token);    
  1616. X    do_plot(first_plot,plot_num,x_min,x_max,y_min,y_max);
  1617. X}
  1618. X
  1619. X
  1620. X
  1621. Xdone(status)
  1622. Xint status;
  1623. X{
  1624. X    if (term)
  1625. X        (*term_tbl[term].reset)();
  1626. X    exit(status);
  1627. X}
  1628. X
  1629. X
  1630. X#ifdef vms
  1631. X
  1632. X#include <descrip.h>
  1633. X#include <rmsdef.h>
  1634. X#include <errno.h>
  1635. X
  1636. Xextern lib$get_input(), lib$put_output();
  1637. X
  1638. Xint vms_len;
  1639. X
  1640. Xunsigned int status[2] = {1, 0};
  1641. X
  1642. X$DESCRIPTOR(prompt_desc,PROMPT);
  1643. X$DESCRIPTOR(line_desc,input_line);
  1644. X
  1645. X$DESCRIPTOR(help_desc,help);
  1646. X$DESCRIPTOR(helpfile_desc,"GNUPLOT$HELP");
  1647. X
  1648. X
  1649. Xread_line()
  1650. X{
  1651. X    switch(status[1] = lib$get_input(&line_desc, &prompt_desc, &vms_len)){
  1652. X        case RMS$_EOF:
  1653. X            done(IO_SUCCESS);    /* ^Z isn't really an error */
  1654. X            break;
  1655. X        case RMS$_TNS:            /* didn't press return in time */
  1656. X            vms_len--;        /* skip the last character */
  1657. X            break;            /* and parse anyway */
  1658. X        case RMS$_BES:            /* Bad Escape Sequence */
  1659. X        case RMS$_PES:            /* Partial Escape Sequence */
  1660. X            sys$putmsg(status);
  1661. X            vms_len = 0;        /* ignore the line */
  1662. X            break;
  1663. X        case SS$_NORMAL:
  1664. X            break;            /* everything's fine */
  1665. X        default:
  1666. X            done(status[1]);    /* give the error message */
  1667. X    }
  1668. X    input_line[vms_len] = '\0';
  1669. X}
  1670. X
  1671. X
  1672. Xdo_help()
  1673. X{
  1674. X    help_desc.dsc$w_length = strlen(help);
  1675. X    if ((vaxc$errno = lbr$output_help(lib$put_output,0,&help_desc,
  1676. X        &helpfile_desc,0,lib$get_input)) != SS$_NORMAL)
  1677. X            os_error("can't open GNUPLOT$HELP");
  1678. X}
  1679. X
  1680. X
  1681. Xdo_shell()
  1682. X{
  1683. X    if ((vaxc$errno = lib$spawn()) != SS$_NORMAL) {
  1684. X        os_error("spawn error",NO_CARET);
  1685. X    }
  1686. X}
  1687. X
  1688. X
  1689. Xdo_system()
  1690. X{
  1691. X    input_line[0] = ' ';    /* an embarrassment, but... */
  1692. X
  1693. X    if ((vaxc$errno = lib$spawn(&line_desc)) != SS$_NORMAL)
  1694. X        os_error("spawn error",NO_CARET);
  1695. X
  1696. X    (void) putc('\n',stderr);
  1697. X}
  1698. X
  1699. X#else /* vms */
  1700. X
  1701. Xdo_help()
  1702. X{
  1703. X    if (system(help))
  1704. X        os_error("can't spawn help",c_token);
  1705. X}
  1706. X
  1707. X
  1708. Xdo_system()
  1709. X{
  1710. X    if (system(input_line + 1))
  1711. X        os_error("system() failed",NO_CARET);
  1712. X}
  1713. X
  1714. X#ifdef MSDOS
  1715. X
  1716. Xread_line()
  1717. X{
  1718. Xregister int i;
  1719. X
  1720. X    input_line[0] = MAX_LINE_LEN - 1;
  1721. X    cputs(PROMPT);
  1722. X    cgets(input_line);            /* console input so CED will work */
  1723. X    (void) putc('\n',stderr);
  1724. X    if (input_line[2] == 26) {
  1725. X        (void) putc('\n',stderr);        /* end-of-file */
  1726. X        done(IO_SUCCESS);
  1727. X    }
  1728. X
  1729. X    i = 0;
  1730. X    while (input_line[i] = input_line[i+2])
  1731. X        i++;        /* yuck!  move everything down two characters */
  1732. X}
  1733. X
  1734. X
  1735. Xdo_shell()
  1736. X{
  1737. Xregister char *comspec;
  1738. X    if (!(comspec = getenv("COMSPEC")))
  1739. X        comspec = "\command.com";
  1740. X    if (spawnl(P_WAIT,comspec,NULL) == -1)
  1741. X        os_error("unable to spawn shell",NO_CARET);
  1742. X}
  1743. X
  1744. X#else /* MSDOS */
  1745. X        /* plain old Unix */
  1746. X
  1747. Xread_line()
  1748. X{
  1749. X    fputs(PROMPT,stderr);
  1750. X    if (!fgets(input_line, MAX_LINE_LEN, stdin)) {
  1751. X        (void) putc('\n',stderr);        /* end-of-file */
  1752. X        done(IO_SUCCESS);
  1753. X    }
  1754. X    else {
  1755. X        input_line[strlen(input_line)-1] = '\0';  /* Remove trailing \n */
  1756. X    }
  1757. X}
  1758. X
  1759. X#ifdef VFORK
  1760. X
  1761. Xdo_shell()
  1762. X{
  1763. Xregister char *shell;
  1764. Xregister int p;
  1765. Xstatic int execstat;
  1766. X    if (!(shell = getenv("SHELL")))
  1767. X        shell = SHELL;
  1768. X    if ((p = vfork()) == 0) {
  1769. X        execstat = execl(shell,shell,NULL);
  1770. X        _exit(1);
  1771. X    } else if (p == -1)
  1772. X        os_error("vfork failed",c_token);
  1773. X    else
  1774. X        while (wait(NULL) != p)
  1775. X            ;
  1776. X    if (execstat == -1)
  1777. X        os_error("shell exec failed",c_token);
  1778. X    (void) putc('\n',stderr);
  1779. X}
  1780. X#else /* VFORK */
  1781. X
  1782. X#define EXEC "exec "
  1783. Xdo_shell()
  1784. X{
  1785. Xstatic char exec[100] = EXEC;
  1786. Xregister char *shell;
  1787. X    if (!(shell = getenv("SHELL")))
  1788. X        shell = SHELL;
  1789. X
  1790. X    if (system(strncpy(&exec[sizeof(EXEC)-1],shell,
  1791. X        sizeof(exec)-sizeof(EXEC)-1)))
  1792. X        os_error("system() failed",NO_CARET);
  1793. X
  1794. X    (void) putc('\n',stderr);
  1795. X}
  1796. X#endif /* VFORK */
  1797. X#endif /* MSDOS */
  1798. X#endif /* vms */
  1799. END_OF_FILE
  1800. if test 23912 -ne `wc -c <'command.c'`; then
  1801.     echo shar: \"'command.c'\" unpacked with wrong size!
  1802. fi
  1803. # end of 'command.c'
  1804. fi
  1805. if test -f 'compile.com' -a "${1}" != "-c" ; then 
  1806.   echo shar: Will not clobber existing file \"'compile.com'\"
  1807. else
  1808. echo shar: Extracting \"'compile.com'\" \(567 characters\)
  1809. sed "s/^X//" >'compile.com' <<'END_OF_FILE'
  1810. X$! make sure you SET TERM/NOWRAP before running GNUPLOT!
  1811. X$ CFLAGS = "NOTHING"
  1812. X$ TERMFLAGS = "AED,HP26,HP75,POSTSCRIPT,QMS,REGIS,TEK,V384,HPLJET"
  1813. X$ set verify
  1814. X$ cc/define=('CFLAGS') command.c
  1815. X$ cc/define=('CFLAGS') eval.c
  1816. X$ cc/define=('CFLAGS') graphics.c
  1817. X$ cc/define=('CFLAGS') internal.c
  1818. X$ cc/define=('CFLAGS') misc.c
  1819. X$ cc/define=('CFLAGS') parse.c
  1820. X$ cc/define=('CFLAGS') plot.c
  1821. X$ cc/define=('CFLAGS') scanner.c
  1822. X$ cc/define=('CFLAGS') standard.c
  1823. X$ cc/define=('CFLAGS','TERMFLAGS') term.c
  1824. X$ cc/define=('CFLAGS') util.c
  1825. X$ cc/define=('CFLAGS') version.c
  1826. X$ set noverify
  1827. END_OF_FILE
  1828. if test 567 -ne `wc -c <'compile.com'`; then
  1829.     echo shar: \"'compile.com'\" unpacked with wrong size!
  1830. fi
  1831. # end of 'compile.com'
  1832. fi
  1833. if test -f 'controls.dem' -a "${1}" != "-c" ; then 
  1834.   echo shar: Will not clobber existing file \"'controls.dem'\"
  1835. else
  1836. echo shar: Extracting \"'controls.dem'\" \(598 characters\)
  1837. sed "s/^X//" >'controls.dem' <<'END_OF_FILE'
  1838. X#
  1839. X# warning:  this demo is SLOW on PCs without math coprocessors!
  1840. X#
  1841. X# From _Automatic_Control_Systems_, fourth ed., figure 6-14
  1842. X# transient response of a second-order system to a unit step input function
  1843. X#
  1844. Xdamp(t) = exp(-s*wn*t)/sqrt(1.0-s*s)
  1845. Xper(t) = sin(wn*sqrt(1.0-s**2)*t - atan(-sqrt(1.0-s**2)/s))
  1846. Xc(t) = 1-damp(t)*per(t)
  1847. X#
  1848. X#    wn is natural undamped frequency
  1849. X#    s is damping factor
  1850. X#
  1851. Xwn = 1.0
  1852. Xset xrange [0:13]
  1853. Xset samples 50
  1854. Xset dummy t
  1855. X#
  1856. X# plot c(t) for several different damping factors s
  1857. X#
  1858. Xplot s=.1,c(t),s=.3,c(t),s=.5,c(t),s=.7,c(t),s=.9,c(t),s=1.0,c(t),s=1.5,c(t),s=2.0,c(t)
  1859. Xset dummy x
  1860. END_OF_FILE
  1861. if test 598 -ne `wc -c <'controls.dem'`; then
  1862.     echo shar: \"'controls.dem'\" unpacked with wrong size!
  1863. fi
  1864. # end of 'controls.dem'
  1865. fi
  1866. if test -f 'corgraph.asm' -a "${1}" != "-c" ; then 
  1867.   echo shar: Will not clobber existing file \"'corgraph.asm'\"
  1868. else
  1869. echo shar: Extracting \"'corgraph.asm'\" \(2272 characters\)
  1870. sed "s/^X//" >'corgraph.asm' <<'END_OF_FILE'
  1871. XTITLE    Corona graphics module
  1872. X;    Colin Kelley
  1873. X;    January 1987
  1874. X
  1875. Xinclude header.mac
  1876. X
  1877. Xif1
  1878. Xinclude lineproc.mac
  1879. Xendif
  1880. X
  1881. X
  1882. X_text    segment
  1883. X
  1884. Xpublic    _GrInit,_GrReset,_GrOnly,_TxOnly,_GrandTx,_Cor_line,_Cor_mask
  1885. X
  1886. Xcorpixel proc near
  1887. X    ror word ptr linemask,1
  1888. X    jc cont
  1889. X    ret
  1890. Xcont:    push bp
  1891. X    mov bp,sp
  1892. X    push ax
  1893. X    push bx
  1894. X    push cx
  1895. X    mov es,ScSeg
  1896. X    shl bx,1            ; y
  1897. X    mov bx,word ptr LookUp[bx] ; bx has y mem address
  1898. X    mov cl,al            ; x
  1899. X    and cl,7
  1900. X    shr ax,1
  1901. X    shr ax,1
  1902. X    shr ax,1            ; ax /= 8
  1903. X    add bx,ax
  1904. X    mov al,1
  1905. X    shl al,cl            ; al contains bit mask
  1906. X    or byte ptr es:[bx],al
  1907. X    pop cx
  1908. X    pop bx
  1909. X    pop ax
  1910. X    pop bp
  1911. X    ret
  1912. X
  1913. Xlineproc _Cor_line, corpixel
  1914. X
  1915. Xbeginproc _GrInit
  1916. X    push bp
  1917. X    mov bp,sp
  1918. X    push di
  1919. X    mov ax, [bp+X]            ; screen number (0 - 7)
  1920. X    mov cl,11
  1921. X    shl ax,cl            ; multiply by 2048 to get segment
  1922. X    mov ScSeg,ax            ; save segment for later
  1923. X    push ax
  1924. X    mov es, ax
  1925. X    xor ax,ax
  1926. X    mov di,ax
  1927. X    mov cx, 4000h
  1928. X    cld
  1929. X    rep stosw
  1930. X    pop cx
  1931. X    call near ptr GrAddr
  1932. X    mov ax,es
  1933. X    pop di
  1934. X    pop bp
  1935. X    ret
  1936. X_GrInit    endp
  1937. X
  1938. Xbeginproc _GrReset
  1939. X    mov cx, 0
  1940. X    call near ptr GrAddr
  1941. X    ret
  1942. X_GrReset endp
  1943. X
  1944. XGrAddr    proc near
  1945. X    mov dx,3b4h            ; address of 6845
  1946. X    mov al,0ch            ; register 12
  1947. X    out dx,al
  1948. X    inc dx
  1949. X    mov al,ch            ; Graphics Segment High
  1950. X    out dx,al
  1951. X    dec dx
  1952. X    mov al,0dh            ; register 13
  1953. X    out dx,al
  1954. X    mov al,cl            ; Graphics Segment Low
  1955. X    inc dx
  1956. X    out dx,al
  1957. X    ret
  1958. XGrAddr    endp
  1959. X
  1960. Xbeginproc _GrOnly
  1961. X    mov dx,3b8h
  1962. X    mov al,0a0h
  1963. X    out dx,al
  1964. X    ret
  1965. X_GrOnly    endp
  1966. X
  1967. Xbeginproc _TxOnly
  1968. X    mov dx,3b8h
  1969. X    mov al,28h
  1970. X    out dx,al
  1971. X    ret
  1972. X_TxOnly    endp
  1973. X
  1974. Xbeginproc _GrandTx
  1975. X    mov dx,3b8h
  1976. X    mov al,0a8h
  1977. X    out dx,al
  1978. X    ret
  1979. X_GrandTx endp
  1980. X
  1981. Xbeginproc _Cor_mask
  1982. X    push bp
  1983. X    mov bp,sp
  1984. X    mov ax,[bp+x]            ; mask
  1985. X    mov linemask,ax
  1986. X    pop bp
  1987. X    ret
  1988. X_Cor_mask endp
  1989. X
  1990. Xcorpixel endp
  1991. X
  1992. X_text    ends
  1993. X
  1994. X_data    segment
  1995. Xlinemask dw -1
  1996. XScSeg    dw 0
  1997. X_data    ends
  1998. X
  1999. Xconst    segment
  2000. X
  2001. XK    equ 1024
  2002. X
  2003. Xmem_mac    MACRO x
  2004. X    dw x,2*K+x,4*K+x,6*K+x,8*K+x,10*K+x,12*K+x,14*K+x,16*K+x
  2005. X    dw 18*K+x,20*K+x,22*K+x,24*K+x
  2006. X    ENDM
  2007. XLookUp    equ $
  2008. X    mem_mac 0
  2009. X    mem_mac 80
  2010. X    mem_mac (80*2)
  2011. X    mem_mac (80*3)
  2012. X    mem_mac (80*4)
  2013. X    mem_mac (80*5)
  2014. X    mem_mac (80*6)
  2015. X    mem_mac (80*7)
  2016. X    mem_mac (80*8)
  2017. X    mem_mac (80*9)
  2018. X    mem_mac (80*10)
  2019. X    mem_mac (80*11)
  2020. X    mem_mac (80*12)
  2021. X    mem_mac (80*13)
  2022. X    mem_mac (80*14)
  2023. X    mem_mac (80*15)
  2024. X    mem_mac (80*16)
  2025. X    mem_mac (80*17)
  2026. X    mem_mac (80*18)
  2027. X    mem_mac (80*19)
  2028. X    mem_mac (80*20)
  2029. X    mem_mac (80*21)
  2030. X    mem_mac (80*22)
  2031. X    mem_mac (80*23)
  2032. X    mem_mac (80*24)
  2033. X
  2034. Xconst    ends
  2035. X
  2036. X    end
  2037. END_OF_FILE
  2038. if test 2272 -ne `wc -c <'corgraph.asm'`; then
  2039.     echo shar: \"'corgraph.asm'\" unpacked with wrong size!
  2040. fi
  2041. # end of 'corgraph.asm'
  2042. fi
  2043. if test -f 'corplot.c' -a "${1}" != "-c" ; then 
  2044.   echo shar: Will not clobber existing file \"'corplot.c'\"
  2045. else
  2046. echo shar: Extracting \"'corplot.c'\" \(839 characters\)
  2047. sed "s/^X//" >'corplot.c' <<'END_OF_FILE'
  2048. X#include <stdio.h>
  2049. X#include <process.h>
  2050. X#include <dos.h>
  2051. X
  2052. X#define BOUNDARY 32768
  2053. X#define segment(addr) (FP_SEG(m) + ((FP_OFF(m)+15) >> 4));
  2054. X#define round(value,boundary) (((value) + (boundary) - 1) & ~((boundary) - 1))
  2055. X
  2056. Xchar *malloc(),*realloc();
  2057. X
  2058. Xchar prog[] = "gnuplot";
  2059. Xchar corscreen[] = "CORSCREEN=0";
  2060. X
  2061. Xmain()
  2062. X{
  2063. Xregister unsigned int segm,start;
  2064. Xchar *m;
  2065. X    if (!(m = malloc(BOUNDARY))) {
  2066. X        printf("malloc() failed\n");
  2067. X        exit(1);
  2068. X    }
  2069. X    segm = segment(m);
  2070. X    start = round(segm,BOUNDARY/16);
  2071. X
  2072. X    if (realloc(m,BOUNDARY+(start-segm)*16) != m) {
  2073. X        printf("can't realloc() memory\n");
  2074. X        exit(2);
  2075. X    }
  2076. X
  2077. X    if ((segm = start >> 11) >= 8) {
  2078. X        printf("not enough room in first 256K\n");
  2079. X        exit(3);
  2080. X    }
  2081. X
  2082. X    corscreen[sizeof(corscreen)-2] = '0' + segm;
  2083. X    if (putenv(corscreen))
  2084. X        perror("putenv");
  2085. X
  2086. X    if (spawnlp(P_WAIT,prog,prog,NULL))
  2087. X        perror("spawnlp");
  2088. X}
  2089. END_OF_FILE
  2090. if test 839 -ne `wc -c <'corplot.c'`; then
  2091.     echo shar: \"'corplot.c'\" unpacked with wrong size!
  2092. fi
  2093. # end of 'corplot.c'
  2094. fi
  2095. if test ! -d 'docs' ; then
  2096.     echo shar: Creating directory \"'docs'\"
  2097.     mkdir 'docs'
  2098. fi
  2099. if test -f 'eval.c' -a "${1}" != "-c" ; then 
  2100.   echo shar: Will not clobber existing file \"'eval.c'\"
  2101. else
  2102. echo shar: Extracting \"'eval.c'\" \(3101 characters\)
  2103. sed "s/^X//" >'eval.c' <<'END_OF_FILE'
  2104. X/*
  2105. X *
  2106. X *    G N U P L O T  --  eval.c
  2107. X *
  2108. X *  Copyright (C) 1986, 1987  Colin Kelley, Thomas Williams
  2109. X *
  2110. X *  You may use this code as you wish if credit is given and this message
  2111. X *  is retained.
  2112. X *
  2113. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  2114. X *  included in later releases.
  2115. X *
  2116. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  2117. X */
  2118. X
  2119. X#include <stdio.h>
  2120. X#include "plot.h"
  2121. X
  2122. Xchar *malloc();
  2123. X
  2124. Xextern int c_token;
  2125. Xextern struct ft_entry ft[];
  2126. Xextern struct udvt_entry *first_udv;
  2127. Xextern struct udft_entry *first_udf;
  2128. Xextern struct at_type at;
  2129. Xextern struct lexical_unit token[];
  2130. X
  2131. Xstruct value *integer();
  2132. X
  2133. X
  2134. X
  2135. Xstruct udvt_entry *
  2136. Xadd_udv(t_num)  /* find or add value and return pointer */
  2137. Xint t_num;
  2138. X{
  2139. Xregister struct udvt_entry **udv_ptr = &first_udv;
  2140. X
  2141. X    /* check if it's already in the table... */
  2142. X
  2143. X    while (*udv_ptr) {
  2144. X        if (equals(t_num,(*udv_ptr)->udv_name))
  2145. X            return(*udv_ptr);
  2146. X        udv_ptr = &((*udv_ptr)->next_udv);
  2147. X    }
  2148. X
  2149. X    if (!(*udv_ptr = (struct udvt_entry *)
  2150. X        malloc((unsigned int)sizeof(struct udvt_entry))))
  2151. X            int_error("not enought memory for value",t_num);
  2152. X    (*udv_ptr)->next_udv = NULL;
  2153. X    copy_str((*udv_ptr)->udv_name,t_num);
  2154. X    (*udv_ptr)->udv_value.type = INT;    /* not necessary, but safe! */
  2155. X    (*udv_ptr)->udv_undef = TRUE;
  2156. X    return(*udv_ptr);
  2157. X}
  2158. X
  2159. X
  2160. Xstruct udft_entry *
  2161. Xadd_udf(t_num)  /* find or add function and return pointer */
  2162. Xint t_num; /* index to token[] */
  2163. X{
  2164. Xregister struct udft_entry **udf_ptr = &first_udf;
  2165. X
  2166. X    while (*udf_ptr) {
  2167. X        if (equals(t_num,(*udf_ptr)->udf_name))
  2168. X            return(*udf_ptr);
  2169. X        udf_ptr = &((*udf_ptr)->next_udf);
  2170. X    }
  2171. X    if (!(*udf_ptr = (struct udft_entry *)
  2172. X        malloc((unsigned int)sizeof(struct udft_entry))))
  2173. X            int_error("not enought memory for function",t_num);
  2174. X    (*udf_ptr)->next_udf = (struct udft_entry *) NULL;
  2175. X    (*udf_ptr)->definition = NULL;
  2176. X    (*udf_ptr)->at = NULL;
  2177. X    copy_str((*udf_ptr)->udf_name,t_num);
  2178. X    (void) integer(&((*udf_ptr)->dummy_value), 0);
  2179. X    return(*udf_ptr);
  2180. X}
  2181. X
  2182. X
  2183. Xunion argument *
  2184. Xadd_action(sf_index)
  2185. Xenum operators sf_index;        /* index of p-code function */
  2186. X{
  2187. X    if (at.a_count >= MAX_AT_LEN)
  2188. X        int_error("action table overflow",NO_CARET);
  2189. X    at.actions[at.a_count].index = sf_index;
  2190. X    return(&(at.actions[at.a_count++].arg));
  2191. X}
  2192. X
  2193. X
  2194. Xint standard(t_num)  /* return standard function index or 0 */
  2195. X{
  2196. Xregister int i;
  2197. X    for (i = (int)SF_START; ft[i].f_name != NULL; i++) {
  2198. X        if (equals(t_num,ft[i].f_name))
  2199. X            return(i);
  2200. X    }
  2201. X    return(0);
  2202. X}
  2203. X
  2204. X
  2205. Xexecute_at(at_ptr)
  2206. Xstruct at_type *at_ptr;
  2207. X{
  2208. Xregister int i,index,count,offset;
  2209. X
  2210. X    count = at_ptr->a_count;
  2211. X    for (i = 0; i < count;) {
  2212. X        index = (int)at_ptr->actions[i].index;
  2213. X        offset = (*ft[index].func)(&(at_ptr->actions[i].arg));
  2214. X        if (is_jump(index))
  2215. X            i += offset;
  2216. X        else
  2217. X            i++;
  2218. X    }
  2219. X}
  2220. X
  2221. X/*
  2222. X
  2223. X 'ft' is a table containing C functions within this program. 
  2224. X
  2225. X An 'action_table' contains pointers to these functions and arguments to be
  2226. X passed to them. 
  2227. X
  2228. X at_ptr is a pointer to the action table which must be executed (evaluated)
  2229. X
  2230. X so the iterated line exectues the function indexed by the at_ptr and 
  2231. X passes the address of the argument which is pointed to by the arg_ptr 
  2232. X
  2233. X*/
  2234. END_OF_FILE
  2235. if test 3101 -ne `wc -c <'eval.c'`; then
  2236.     echo shar: \"'eval.c'\" unpacked with wrong size!
  2237. fi
  2238. # end of 'eval.c'
  2239. fi
  2240. echo shar: End of archive 1 \(of 7\).
  2241. cp /dev/null ark1isdone
  2242. MISSING=""
  2243. for I in 1 2 3 4 5 6 7 ; do
  2244.     if test ! -f ark${I}isdone ; then
  2245.     MISSING="${MISSING} ${I}"
  2246.     fi
  2247. done
  2248. if test "${MISSING}" = "" ; then
  2249.     echo You have unpacked all 7 archives.
  2250.     rm -f ark[1-9]isdone
  2251. else
  2252.     echo You still need to unpack the following archives:
  2253.     echo "        " ${MISSING}
  2254. fi
  2255. ##  End of shell archive.
  2256. exit 0
  2257.